Background Color:
 
Background Pattern:
Reset
Search

Forum

Please Log In

We want you to contribute! 

This forum is a moderated environment. 
We try to keep it neat and tidy. In order to access the forum content we would like you to either or register.

HomeHomeScryberScryberDevelopment Que...Development Que...Using compiled resources to generate pdfUsing compiled resources to generate pdf
Previous
 
Next
New Post
5/11/2017 5:18 PM
 

My .pdfx are all compiled with my .exe i have to write the .pdfx to disk with a custom function to be able to load it with :

 

PDFDocument doc = PDFDocument.ParseDocument(PdfHelper.GetPdfTemplatePath("ActionReport.pdfx"));

 

Same for images.. I have many images I would like to use in my pdf, they are all internal resources, is their not a function to retrieve image from bytestream or do I have to write it to disk aswell?

 

Thank you for all your replies.

 
New Post
5/11/2017 5:48 PM
 

Hey Mehim

There are a number of overloads to the ParseDocument method that will take readers and streams. There are also a significant number of static Parse methods that will take readers, settings, reference resolvers and strings which are more generic (returning the parsed object as an IPDFComponent), but will still generate the correct type.

For the images you can use the dynamic image options that will allow you to load image data from wherever you need to based on matching a regular expression.
(http://www.scryber.co.uk/HowTo/tabid/133/topic/Image/Default.aspx#Dynamic)

And the fonts config section will support any ttf files you need to ensure are available on the machine executing the assembly but may not be installed through the resources.
(http://www.scryber.co.uk/HowTo/tabid/133/Default.aspx?topic=Scryber+Configuration#fonts)


Richard

 
New Post
5/11/2017 6:07 PM
 

Thanks for reply.

Yes I did see the static parse methods but it still asks for a source and a resolver of which i can find no information, so I am slightly confused as how to call the Parse method, if you could enlighten me.. 

public static Scryber.IPDFComponent Parse(string source, System.IO.TextReader textreader, Scryber.PDFReferenceResolver resolver)

As for the ParseDocument method I see no other overloads other then ParseDocument(string) in the object browser..

 

 

 
New Post
5/11/2017 6:59 PM
 

Aah Mehim - you are correct on the current released version 

My bad - we have extended these options significantly in v1.0. 

However the Parse method is pretty simple. The source parameter is simply a unique identifier and the reference resolver is a delegate used to return relative parsed components referenced within the file. The below should help.


private PDFDocument ParseMyDocument(string rsrcname, System.IO.Stream data)

{

    PDFReferenceResolver resolver = new PDFReferenceResolver(MyResourceReferenceResolver);

    return PDFDocument.Parse(rsrcname, data, resolver) as PDFDocument;

}

 

private IPDFComponent MyResourceReferenceResolver(string rsrcname, string xpath, Generation.PDFGeneratorSettings settings)

{

    using(System.IO.Stream data = GetMyResource(rsrcname))

    {

        PDFReferenceResolver method = settings.Resolver; //actually refers to this method anyway - should be checking for circular references too :-)

        //if you wanted to you could also use the xpath parameter to select nodes within the xml data stream before parsing .

        return PDFDocument.Parse(rsrcname, data, method, settings);

    }

}

 

 
New Post
5/11/2017 7:23 PM
 

Awesome! Thanks for explanations, I will fiddle with it in the morning. v1.0? great didn't know it was still under development.

Great piece of software, I love the concept of decoupling the visual aspect from the code aspect, the templates, the ML style syntax etc..

Will more then probably be purchasing a licence for our software. Keep up the good work. 

Documentation is lacking, sometimes confusing.. some of the syntax is wrong (or my XML knowledge is really lacking) thankefully the forums have helped me a lot.

 

Again thanks for the input!

 

Tim

 

 

 

 
New Post
5/11/2017 7:46 PM
 

Thanks Tim

 

Yeah - v1 is there, but just need to release it along with some extensions. And I'm well aware the documentation is aged and definitely lacking (much rather code :-))

 

R

 
New Post
5/11/2017 7:57 PM
 

"And I'm well aware the documentation is aged and definitely lacking (much rather code :-))"

haha as do we all :P just hoping its not making people turn away from it ($$?), 

I have gone through dozens of libraries and Scryber is perfect for MVVM integration in a C#/WPF environment, it integrates perfectly with so little code to generate a pdf compared to other solutions. Binding? Godsend! Its just logical to use ML for visual portions especially in a WPF env, i'm just suprised it is not the defacto standard pdf library!

Laters and thanks,

 

Tim

 

 
New Post
5/12/2017 8:56 AM
 

Got it working many thanks! I dont like excessive read/writes when its allready in memory :P

 
Previous
 
Next
HomeHomeScryberScryberDevelopment Que...Development Que...Using compiled resources to generate pdfUsing compiled resources to generate pdf