Print Page | Close Window

Hanlde Multiple PDF Pages to Multiple Pages TIFF

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3776
Printed Date: 27 Apr 24 at 5:41AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Hanlde Multiple PDF Pages to Multiple Pages TIFF
Posted By: rocky1
Subject: Hanlde Multiple PDF Pages to Multiple Pages TIFF
Date Posted: 23 Jan 20 at 10:58AM
Hi I am Currently using 
DebenuPDFLibraryDLL1011 at my end.

I am trying to read the multiple pages pdf file into a multiple tiff or into a byte stream 
can it possibly done by using RenderPageToString ?
Here is my sample code
List<Bitmap> listOfImages = new List<Bitmap>();

                PDFLibrary PL = new PDFLibrary(strDLLPath);

                if (PL.LibraryLoaded())
                {
                    PL.UnlockKey(PdfTask.DebenuPDFLibraryUnlockKey);
                    PL.LoadFromFile(strFileName, string.Empty);
                    const float renderDPI = 180;
                    int intPageCount = PL.PageCount();

                    for (int intPageIndex = 1; intPageIndex <= intPageCount; intPageIndex++)
                    {
                        // PDF to bitmap
                        byte[] bytesPageBitmap = PL.RenderPageToString(renderDPI, intPageIndex, 7);
                        MemoryStream msPageBitmap = new MemoryStream(bytesPageBitmap);
                        Bitmap pageBitmap = (Bitmap)Image.FromStream(msPageBitmap);
                        pageBitmap.SetResolution(renderDPI, renderDPI);

                        listOfImages.Add(pageBitmap);
                    }

                }




Replies:
Posted By: rocky1
Date Posted: 23 Jan 20 at 4:11PM
Can anyone help me out here?


Posted By: tfrost
Date Posted: 23 Jan 20 at 7:55PM
I am afraid am not familiar with the DLL interface, or with using QuickPDF in ths way.  But in general, precisely what problems to you see when you run this code in your debugger? What data actually turns up in the string and does it look like a bitmap?  Have you tried RenderAsMultipageTIFFToFile ?


Posted By: Ingo
Date Posted: 23 Jan 20 at 9:58PM
Hi Rocky,

Here it's the other way round to give you an idea what could be possible:
https://www.debenu.com/kb/create-a-multi-page-pdf-from-a-multi-page-tiff-programmatically/

This is the function Tim (TFrost) is talking about. It should feed your needs:
https://www.debenu.com/docs/pdf_library_reference/RenderAsMultipageTIFFToFile.php
There's a stream version, too.

I don't have samples regarding this functionality but the developer guide and the online reference will help as well.

BTW: There's no need to ask again after some hours. Here's not too much traffic and not all members are familiar with all issues. So sometimes you have to do the first steps with your problem alone and if you have solve your problem you can post the solution here (in the samples section) to help the other ones ;-)



-------------
Cheers,
Ingo



Posted By: rocky1
Date Posted: 24 Jan 20 at 7:33AM
Hi tfrost,
Thanks for the response 
as I did tried using RenderAsMultipageTIFFToFile and I was able to successfully convert the Multiple Page PDF doc to Multiple Tiff File

But there's only one problem to it - when it is converting to the GrayScale it is skipping the PDF header image.

Here's my sample Code which is working -
              //DLL file path
                string strDLLPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                    PdfTask.DebenuPDFLibraryDLL);

                PDFLibrary PL = new PDFLibrary(strDLLPath);

                if (PL.LibraryLoaded())
                {
                    PL.UnlockKey(PdfTask.DebenuPDFLibraryUnlockKey);

                    var strFileName = @"H:\SampleFile\samplecolor.pdf";
                    PL.LoadFromFile(strFileName, string.Empty);
                    const float renderDPI = 180;

                    int intPageCount = PL.PageCount();
                    int xx = PL.RenderAsMultipageTIFFToFile(renderDPI, "1-5", 1, 0, @"D:\aaaaa.tif");
                    if (xx == 1)
                    {
                    }


Here's the PDF Image -
https://imgbbb.com/image/L3pvmU" rel="nofollow - https://imgbbb.com/image/L3pvmU

Here's is the TIFF Image when converted to grayscale -
https://imgbbb.com/image/L3pw8v 


All the pages are writing under Tiff correctly only thing it is skipping the header part not sure what I am doing wrong this problem only comes when writing into the grayscale mode 



Posted By: tfrost
Date Posted: 24 Jan 20 at 12:23PM
Sorry, that website does not let me dowload your PDF, even after creating an account, so there is not much more I can say about what the problem might be.  If I had the PDF, I could at least tell you whether it converts correctly for me in QuickPDF, with our PDF to TIFF tools.


Posted By: rocky1
Date Posted: 24 Jan 20 at 1:33PM
Hi tfrost 
Here's the PDF which I am using currently

Link to Download
https://drive.google.com/open?id=1_p73bHv2bZx5v_PlGMeA6dTY0rAUL4ye" rel="nofollow - https://drive.google.com/open?id=1_p73bHv2bZx5v_PlGMeA6dTY0rAUL4ye




Posted By: Ingo
Date Posted: 24 Jan 20 at 2:26PM
perhaps the problem is that the header of the pdf-page was an embedded image?
What about rendering the page to any other coloured image type... how it looks like?
BTW: Till now each new version comes along with enhancements and fixes regarding rendering. Then i see that you're still using version 10.11 - so a test from Tim with an actual version of the library could be very useful for you...



-------------
Cheers,
Ingo



Posted By: rocky1
Date Posted: 24 Jan 20 at 2:34PM
Hi Ingo, 
Yes the other Colored image type is working fine. It has no issues.
I am not sure whether its an embedded image or not. 
I am just using a sample pdf for my test cases.
Thanks


Posted By: tfrost
Date Posted: 25 Jan 20 at 12:04AM
The whole document renders to gray for me with v17.11, and nothing seems to be missing.  If you are using the function I suggested both for colour (option 0) and grayscale (1) and only the former produces the correct output, then it is probably an issue in the old version of QPDF you are using.  I always convert to colour BMP first, then use our own dithering options to get the maximum quality B/W image for faxing. We need complete control over the resolution, size and quality.  If you need true grayscale output rather than monochrome, I would convert the color to grayscale after creating the image from QPDF. In my TIF the 200dpi output is a bit fuzzy because hardly any of the original text is black.

I will try to find a convenient way to get the TIF I have created to you.  But all the work we do is the colour to monochrome; rendering the colour output from QuickPDF is the simple part!


Posted By: rocky1
Date Posted: 27 Jan 20 at 6:29AM
Thanks for the Update tfrost,
so as i am using  QPDF -  DebenuPDFLibraryDLL1011 v 10.11  can you please let me know the process require to update as I am already having a license key for v10.11
1.Do I need to buy the new version of QPDF?
2.Will my existing license key supports the updated version of  QPDF?
3. Will an update cost to me? or if there's any link where I can look into it it will be really helpful.

Thanks



Posted By: tfrost
Date Posted: 27 Jan 20 at 8:44AM
You will need to contact Foxit if you want to upgrade.  This is a user forum.  You can also perhaps get a trial of the later release to test if the rendering is improved.

And please note that I am using Delphi, not the DLL version.  So the functions I am using which render directly to bitmaps are much more convenient than those in the DLL, and my processing of the colour bitmaps afterwards to create multi-page monochrome TIF is our own code, not in QuickPDF.  But the PDF rendering should be common to both editions


Posted By: Ingo
Date Posted: 27 Jan 20 at 11:31AM
ask for a testversion to evaluate:
https://www.debenu.com/products/development/debenu-pdf-library/trial/

where to buy the latest version of the library:
https://www.debenu.com/store/buy-quick-pdf-library/

for upgrade prices of the library:
https://www.debenu.com/store/buy-quick-pdf-library-upgrade/




-------------
Cheers,
Ingo



Posted By: rocky1
Date Posted: 27 Jan 20 at 1:54PM
Thank you for the update.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk