I would like to put a specific color to a svg that i insert in a PDF thanks to TCPDF
this color will allow a printer to cut automatically
I know i would have to use spotcolors.
as here: https://tcpdf.org/examples/example_037/
the SetFillSpotColor function works perfectly for text or a rectangle
but when I use ImageSVG this has no effect
i add name CutContour directly in svg, example :
<path fill="CutContour" d="M271.44,849.229c-1.254,0.174-2.604,0.489-3,0.701...
but not works too.
example my code PHP:
$pdf->AddSpotColor('CutContour', 0, 0, 0, 100);
$pdf->ImageSVG( $filename_svg , 0, 0, $largeurmm, $hauteurmm, 'CutContour', false, false, 0, false);
I can't find a solution,
can you help me?
I'm guessing you can't get away with using cutcontour as the spot color name, correct? The ImageSVG parser appears to force the color name to lowercase, which means it doesn't match against the CutContour name when it goes to look for it in the TCPDF instance's list of added spot colors.
If that guess is correct, try adding the color to the predefined list in the TCPDF_COLORS class (see spotcolor static property), either by editing include/tcpdf_colors.php or adding a line like this to your script.
TCPDF_COLORS::$spotcolor['cutcontour'] = array( 0, 0, 0, 100, 'CutContour');
$pdf->AddSpotColor('CutContour', 0, 0, 0, 100);
This way, when it goes to look for the lowercase name, it'll find a match and return the proper spot color array. (Note: Tested in TCPDF 6.2.17)
Related
Trying to set the height along with setting the rotation on a Paragraph object results in the following error:
ERROR c.i.layout.renderer.BlockRenderer - Rotation was not correctly processed for ParagraphRenderer
Also, the height is sent to infinity resulting in an apparently empty page which I'm not sure if it's the expected behavior or not.
If I don't set the height, the text shows up rotated (which is what I want). But my task is to place the text at certain coordinates with certain dimensions and rotation. The placement is fine, but not being able to set the height results in assigning the rotation points to the wrong values and in turn displacing the final position of the text.
Paragraph paragraph = new Paragraph(text);
paragraph.setHeight(height);
paragraph.setMargins(0, 0, 0, 0);
paragraph.setProperty(ROTATION_POINT_X, x);
paragraph.setProperty(ROTATION_POINT_Y, y);
paragraph.setProperty(ROTATION_ANGLE, asFloat(toRadians(rotation))));
document.add(paragraph);
Setting the margins to 0 doesn't seem to have any influence either. The text looks to keep some sort of margin anyway.
So is there a way to control what the dimensions of the object displayed are? I could also settle for a way to make the rotation pivot from the center of the object.
You should set both width and height at the same time for rotated objects.
Here is an example code:
Paragraph paragraph = new Paragraph("Hello world");
paragraph.setWidth(200);
paragraph.setHeight(20);
paragraph.setBackgroundColor(ColorConstants.RED);
paragraph.setMargins(0, 0, 0, 100);
paragraph.setProperty(ROTATION_POINT_X, paragraph.getWidth().getValue() / 2);
paragraph.setProperty(ROTATION_POINT_Y, paragraph.getHeight().getValue() / 2);
paragraph.setRotationAngle(Math.PI / 180 * 45);
document.add(paragraph);
Visual result:
I am drawing a simple straight line on an image which is already drawn at the drawing area.
But at one unix machine, the drawn line in black color instead of red color.
Following is the piece of code to draw straight line:
Gdk::Color red("red");
//winPtr is type of Gtk::Window*
Glib::RefPtr<Gdk::GC> gc = winPtr->get_window()->get_style()->get_white_gc();
gc->set_line_attributes ( 2, (Gdk::LineStyle)0, (Gdk::CapStyle)2, (Gdk::JoinStyle)1);
Glib::RefPtr<Gdk::Visual> some_visual;
some_visual = Gdk::Visual::get_best();
Glib::RefPtr<Gdk::Colormap> some_colormap = Gdk::Colormap::create(some_visual, true);
some_colormap->alloc_color (red, false, true);
gc->set_colormap(some_colormap);
gc->set_foreground(red);
imgDispArea->get_window()->draw_line ( gc, 100, 100, 200, 200);
PS : -- Where "imgDispArea" is a type Gtk::DrawingArea*
Any help is appreciated.
My best guess here is that the problematic unix machine the X11 rgb.txt file is different. Per the GdkColor documentation:
The string can either one of a large set of standard names (taken from the X11 rgb.txt file) or ...
My suggestion would be to specify the color as "#FF0000" rather than "red".
I need to attach footer at the very bottom of every page. I am using tcpdf for generating pdf's. i tried many solution on google but did not found any luck. My current framework is yii and i am using tcpdf extension.
you need to write Footer method in your class for example
// Page footer
public function Footer() {
// Position at 15 mm from bottom
$this->SetY(-15);
// Set font
$this->SetFont('helvetica', 'I', 8);
// Page number
$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
Well, if you're subclassing the tcpdf class, just add a public function Footer() in which you do your stuff. It might help to set the bottom page margin to a sensible value before doing the content work, so that the Footer function has "space" to put in the footer.
why don't you try mpdf extension i am not sure if you can get its library for yii but it has one for codeigniter and it is awesome converts css + Html to pdf accurately.
I'm trying to make a mixin with multiple variables in LESS, but for some reason it's not working. I have this LESS:
.rgbabg(#r: 0, #g: 0, #b: 0, #a: .5) {
#val: rgba(#r, #g, #b, #a);
background: #val;
}
I call it like this:
.rgbabg(255, 0, 0, .5);
But I don't get any background on my element at all. Is my syntax ok?
Your syntax of your mixin is fine, and it compiles fine. I tried it out in my LESS converter and it's all good. I applied the rule to a page for an a tag selector:
a {
.rgbabg(255);
}
And it outputs:
a {
background: rgba(255, 0, 0, 0.5);
}
which colors my links just like it sounds like it should.
What version of LESS are you compiling with - what platform and version of the complier? I wouldn't recommend the Ruby compiler as I don't think it's kept up much anymore, and all the cool new features and support are on the Javascript less.js project. If you're doing it in PHP or .NET then you should check with those projects respectively.
I'm building a kind of dock, and I struggle at finding how to save things like "Run", "Search", "Help", "Printers" and reopen them after that.
I tried this :
CComPtr<IShellFolder> pDF;
SHGetDesktopFolder(&pDF);
LPITEMIDLIST pidlPrintersAndFaxes=0;
hr=pDF->ParseDisplayName(0, 0, L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}", 0, &pidlPrintersAndFaxes, NULL);
CComPtr<IShellFolder> pSF;
hr=pDF->BindToObject(pidlPrintersAndFaxes, 0, IID_IShellFolder, (void**)&pSF);
LPITEMIDLIST pidlPrinter=0;
hr=pSF->ParseDisplayName(0, 0, L"PDFCreator", 0, &pidlPrinter, NULL);
CComPtr<IContextMenu> pPrinterCtxMenu;
hr=pSF->GetUIObjectOf(0, 1, (LPCITEMIDLIST*)&pidlPrinter, IID_IContextMenu, 0, (void**)&pPrinterCtxMenu);
CMINVOKECOMMANDINFO cmd={0};
cmd.cbSize=sizeof(CMINVOKECOMMANDINFO);
cmd.lpVerb=MAKEINTRESOURCE(0);
cmd.nShow=SW_SHOWNORMAL;
hr=pPrinterCtxMenu->InvokeCommand(&cmd);
Whatever I try InvokeCommand on the last line always return E_INVALIDARG. I tried it with ShellExecuteEx and got the same error.
I tried every possible verbs.
I tried to enumerate the verbs and got E_INVALIDARG.
I can't make it work but on normal filesystem path like "c:\" and clsid on folders. What did I miss ?
I found the solution. I must create a context menu, then QueryContextMenu to fill it, get the default item with GetDefaultMenuItem() and invoke it with InvokeCommand.
It is necessary to substract the index of the first item given to QueryContextMenu from the default menu item, because otherwise you'll have an offset.
This was very helpful : http://blogs.msdn.com/oldnewthing/archive/2004/09/30/236133.aspx