how could i generate thumb from pdf and image?

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

how could i generate thumbnail from any pdf & image file and store into MemoryStream or into byte?
I refer https://sdkhelp.pdf-xchange.com/vie ... ilCallback link but it doesn't make any seance.

i'm looking forward to it.
thanks in advance.
:)
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17910
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: how could i generate thumb from pdf and image?

Post by Tracker Supp-Stefan »

Hello Vivek,

You posted in the end user forums, so I will move your question to the appropriate Editor SDK one.

Regards,
Stefan
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

I want to do this by simple document file rather then pdf control, that you did in attached zip file of https://forum.pdf-xchange.com/ ... 39#p109139 link.
so, it's possible??
if, yse than how??
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Hello vivekpatel,

Please provide detailed description of what you need only then I can assist further.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

I don't want to use control in project. I want to do this as just like split,Append or like that.
Here I attach zip for your reference.
Attachments
PDF-XchangeDemo_simple.zip
(2.11 MiB) Downloaded 113 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Could you please explain in a few more details what problems are you currently experiencing? What changes have you made to the project so that you are attaching it here? As I have requested before, please describe precisely what you need and why do you need this. Please also note that we won't do the implementation and coding for you, we can just advice and guide you to the correct answer.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

if, there is any other way to create thumbnail?
i don't want to load control on form. Without loading pdfcontrol on form it is possible?
i want to create thumbnail silently.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Hello vivekpatel,

Have you looked at the project's code that you've send us in one of the previous posts?
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

Here i'm attached error and my sample code.
Attachments
My Exa.rar
(170.51 KiB) Downloaded 99 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Hello vivekpatel,

You forgot to initialize the ixcInst - you only declared it but never used a GetExtension("IXC")

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

One More Error.
Attachments
ex2.rar
(77.72 KiB) Downloaded 97 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Hello vivekpatel,

This error was caused by the invalid conversion to the UInteger data type:

Code: Select all

Dim bb() = System.BitConverter.GetBytes(hdc.ToInt32())
Dim MyUint = System.BitConverter.ToUInt32(bb, 0)
iDestPage.DrawToDC(MyUint, 0, 0, iDestPage.Rect.right - iDestPage.Rect.left, iDestPage.Rect.bottom - iDestPage.Rect.top, 0, 0)
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

In the above attachment, CreateThumbnail_PDFX() function retun image.
i want to get the byte.So, What changes need to do?
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: how could i generate thumb from pdf and image?

Post by John - Tracker Supp »

Vivek,

Our development team have asked me to convey to you that they are not here to code your application for you but to assist you with your coding (not providing it) and specifically related to our SDK.

You need to provide sample code that you have created and where you have issues that relate to our functionality.

Please provide code that you need help with and detailed explanation of where you are having issues - otherwise we cannot help.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

This is my sample code.
Attachments
My Exa.rar
(170.51 KiB) Downloaded 101 times
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

How to Convert iDestPage into Byte in MyExa.zip?
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

Dim ms As New MemoryStream
Dim bt() As Byte

Dim srcPage As PDFXEdit.IPXC_Page = CType(IPage, PDFXEdit.IPXC_Page)

Dim pageW, pageH As Double
srcPage.GetDimension(pageW, pageH)
Dim page_pixel_W, page_pixel_H As Integer
page_pixel_W = Pt2Pixel(pageW, dpi)
page_pixel_H = Pt2Pixel(pageH, dpi)

Dim iDestPage As PDFXEdit.IIXC_Page = ixcInst.Page_CreateEmpty(page_pixel_W, page_pixel_H, PDFXEdit.IXC_PageFormat.PageFormat_8RGB, Convert.ToUInt32(1))


Dim destRect As PDFXEdit.tagRECT
destRect.left = 0
destRect.bottom = 0
destRect.right = iDestPage.Width
destRect.top = iDestPage.Height

Dim srcPageMatrix As PDFXEdit.PXC_Matrix = srcPage.GetMatrix(PDFXEdit.PXC_BoxType.PBox_PageBox)
Dim srcRect As PDFXEdit.PXC_Rect = srcPage.Box(PDFXEdit.PXC_BoxType.PBox_PageBox)
srcPageMatrix.a = (destRect.right - destRect.left) / (srcRect.right - srcRect.left)
srcPageMatrix.d = (destRect.top - destRect.bottom) / (srcRect.top - srcRect.bottom)


srcPage.DrawToIXCPage(iDestPage, destRect, srcPageMatrix)

Dim Image As Bitmap = New Bitmap(iDestPage.Rect.right - iDestPage.Rect.left, iDestPage.Rect.bottom - iDestPage.Rect.top)
Dim g As Graphics = Graphics.FromImage(Image)
g.Clear(Color.White)

Dim hdc As IntPtr = g.GetHdc()
Dim bb() = System.BitConverter.GetBytes(hdc.ToInt32())
Dim MyUint = System.BitConverter.ToUInt32(bb, 0)

iDestPage.DrawToDC(MyUint, 0, 0, iDestPage.Rect.right - iDestPage.Rect.left, iDestPage.Rect.bottom - iDestPage.Rect.top, 0, 0)
g.ReleaseHdc(MyUint)


Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png) 'SAVE INTO THE MEMORY STREAM OBJECT
ReDim bt(ms.Length)
ms.Position = 0
ms.Read(bt, 0, System.Convert.ToInt32(ms.Length))
ms.Close() 'CLOSE MEMORYSTREAM
ms.Dispose() 'DISPOSE MEMORYSTREAM


In this Code i got only image with only black or other color when pass Uinteger in "Dim iDestPage As PDFXEdit.IIXC_Page = ixcInst.Page_CreateEmpty(page_pixel_W, page_pixel_H, PDFXEdit.IXC_PageFormat.PageFormat_8RGB, Convert.ToUInt32(1))" code.

I want to get actual image as pdf has, so what to do?
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

It is possible to work with images like TIFF,JPG,GIF,PNG AND RAW IMAGE FILE to generate thumbnail?
if, yes then how to deal with image?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Hello vivekpatel,

In this topic, where you took the sample from, the developer asks the same question, to which I have provided an answer:
https://forum.pdf-xchange.com/ ... 32#p108032
Please try doing the same in your project and see whether it helps. When you will succeed with the Image then we will move to the byte.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

How to get actual color of page in thumbnail?
Attachments
WindowsApplication1.rar
(100.4 KiB) Downloaded 78 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Hello vivekpatel,

What do you mean by that and why do you need that?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

In my Sample code,Thumbnail is generated with specified color in

Dim iDestPage As PDFXEdit.IIXC_Page = ixcInst.Page_CreateEmpty(page_pixel_W, page_pixel_H, PDFXEdit.IXC_PageFormat.PageFormat_8RGB, Convert.ToUInt32(1))

i want the thumbnail with actual pages as pdf has.
This thumbnail is used as page preview in our system.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Have you read my previous post? The image is drawn like that because the code is not correct:
https://forum.pdf-xchange.com/ ... 19#p109319
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

where do i need correction?
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

error in "Iaux_Inst.MathHelper.Rect_Transform(srcPageMatrix, ref srcRect)"
so what i need to do?
Attachments
WindowsApplication1.rar
(101.61 KiB) Downloaded 80 times
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: how could i generate thumb from pdf and image?

Post by Will - Tracker Supp »

Hi Vivek,

Regretably we can only offer assistance related to the functionality and documentation of our SDK's. As this latest is a general coding issue and not related to the functionality of our SDK, you will need to seek assistance elsewhere.

With the best will in the world, from what we've seen so far, we're not entirely sure that our SDK's are suitable for your use; they are incredibly complex and not for novice developers. You will very likely need assistance from a more experienced developer in order to achieve what you need.

Thanks,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello and Thanks,

I resolve my problem with "Iaux_Inst.MathHelper.Rect_Transform(srcPageMatrix, ref srcRect)".
Now i want to create thumbnail of images?

So it's posible with my code?
============================
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

CreateThumb_UsingPDFXEdior("C:\Users\Vivek\Desktop\PDF\Vraj Icon.png")
End Sub
=======================

Public Function CreateThumb_UsingPDFXEdior(ByVal path As String, Optional ByVal CurrentPage As Integer = 1) As Byte()

Dim Doc As PDFXEdit.IPXC_Document = m_pxcInst.OpenDocumentFromFile(path, Nothing)


Dim page As PDFXEdit.IPXC_Page = Doc.Pages(CurrentPage)
ixcInst = m_Inst.GetExtension("IXC")

Dim img As Byte() = CreateThumbnail_PDFX(page, 30)


Doc.Info(PDFXEdit.PXC_DocumentInfoKey.DocInfo_Title) = "PDF"
Dim obj As New XtraForm1(img)
obj.ShowDialog()
Return img
End Function
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Hello vivekpatel,

The thing is that we will need to know where and how exactly is Byte() used. Can you send us the code inside of the XtraForm1(img) so that we would know what do you need inside that byte, only then we can advice further.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,
Sorry for the inconvenience.
Here i'm attaching my Sample.so, easy to understand for you.
Attachments
WindowsApplication1.rar
(100.5 KiB) Downloaded 86 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Hello vivekpatel,

Here's the description:
https://documentation.devexpress.com/#W ... Valuetopic
It says that it can use System.Drawing.Image:
To return the edit value as an System.Drawing.Image object, use the Image property.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
vivekpatel
User
Posts: 141
Joined: Sat Aug 27, 2016 11:00 am

Re: how could i generate thumb from pdf and image?

Post by vivekpatel »

Hello,

i mean to say that,

Dim Doc As PDFXEdit.IPXC_Document = m_pxcInst.OpenDocumentFrom(path, Nothing) ==> Throws An unhandled exception of type 'System.ArgumentException' occurred in WindowsApplication1.exe.
Here i pass image in "path" parameter. So, How to open image like jpg,png,tiff,tif,bmp and others?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: how could i generate thumb from pdf and image?

Post by Sasha - Tracker Dev Team »

Hello vivekpatel,

You will need to handle exceptions by yourself using the try-catch block, as I already described in this post:
https://forum.pdf-xchange.com/ ... 39#p106739
Also, to know precisely what this code means (if it has been returned from our library) use this method:
https://sdkhelp.pdf-xchange.com/vie ... matHRESULT

Please do that and give us the description of the result of the exception then we can advice further.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply