Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, December 5, 2011 2:48:28 AM(UTC)
softwareentwicklung

Groups: Registered
Posts: 5


Hello.

I´m working on a project and I´m using the PDFFile-Class to work with PDF-Files. I extract pages respectivley I merge different documents to a single file (I keep this file in the memory and only after finishing all operations I save it to a file).
I get these files somewhere from the filesystem.
Only in one case, I have to read the PDF from an url. I read this PDF into a stream. My problem is: how do I create a PDFFile-object from this stream. The constructor only accepts a filename. Is there another possibility? I thought it would perhaps be possible to load the stream into a rasterImage. But then again how do I get a PDFFile from this rasterImage?

Could you please give me a hint how to solve this problem?

I use .Net 3.5, C# and the 17.5 Leadtools-Libs.

Many thanks
M.Wagner
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Monday, December 5, 2011 6:24:39 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

You need to find a way to save the stream to a temporary file on disk, and then pass the file to the PDFFile class constructor.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Monday, December 5, 2011 8:59:49 PM(UTC)
softwareentwicklung

Groups: Registered
Posts: 5


Hello,

thanks for your quick response.
I tried to read the pdf-Files with RasterCodecs into an image. Thats generally not a problem, but the problem is that the resolution has only one bit per pixel (bpp). Thats not acceptable.
I can load the file and the info-object says it has 24 bpp, but when I go on and try to save it either to a stream or a file and bpp is higher than 1 I get the exception "Invalid parameter passed".

Is it possible to get a higher resolution. My company is thinking about buying the license for Leadtools 17.5, but if its not possible to get a higher resolution we have to think about that.

Here my code to test the load and save of the pdf-file:

class Merge
    {
        private RasterCodecs codecs = new RasterCodecs();
        private RasterImage fileImage;
        private RasterImage allFilesImage;
        private CodecsImageInfo info;
        private string outfile = @"C:\TEMP\LeadtoolsTests\rasterMerge.pdf";
        private string tmpfile;
        private System.IO.MemoryStream myStream = new System.IO.MemoryStream();

        public void start(string file1, string file2)
        {
            try
            {
                for (int i = 0; i < 2; i++)
                {  
                    tmpfile = @"C:\TEMP\input" + (i+1) + ".pdf";
                    info = codecs.GetInformation(tmpfile, true);
                    fileImage = codecs.Load(tmpfile, info.Width, info.Height, info.BitsPerPixel, RasterSizeFlags.Resample, CodecsLoadByteOrder.RgbOrGray);
                    codecs.Save(fileImage, myStream, RasterImageFormat.RasPdfG4, /*info.BitsPerPixel*/1, 1, info.TotalPages, 1, CodecsSavePageMode.Append);
                }

                info = codecs.GetInformation(myStream, true);
                allFilesImage = codecs.Load(myStream, info.BitsPerPixel, CodecsLoadByteOrder.RgbOrGray, 1, info.TotalPages);
                codecs.Save(allFilesImage, outfile, RasterImageFormat.RasPdfG4, info.BitsPerPixel);

            }
            catch (Exception ex)
            {
                throw;
            }
        }
    }

Many thanks
M.Wagner

 
#4 Posted : Tuesday, December 6, 2011 4:47:28 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

You are trying to save the result PDF file to RasPdfG4 format (Raster PDF with G4 Compression). This compression supports only 1 BPP.
Try to save the PDF file using the RasPdf or RasPdfLzw formats. These formats support 1, 2, 4, 8 and 24 BPP.

Note that you can specify the BPP when loading PDF files by using the codecs.Options.Pdf.Load.DisplayDepth property.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#5 Posted : Thursday, December 8, 2011 10:21:16 PM(UTC)
softwareentwicklung

Groups: Registered
Posts: 5


Thank you very much for your help!
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.096 seconds.